<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
	<button>点我</button>
</body>
<script>
	// 可以先指定回调函数，再更改状态。也可以先更改状态再指定回调函数
	let fn = null;
	const p = new Promise(function(resolve,reject){
		fn = resolve;
	});
	p.then(value=>{
		console.log(value);
	});
	
	document.querySelector("button").onclick = function(){
		fn(100);
	}
</script>
</html>